<template>
  <el-form v-if="type==0" :model="fromData" :rules="fromData_rules" ref="fromDataRef" label-width="100px">
    <el-form-item label="名称" prop="name">
      <el-input :readonly="_readonly" v-model="fromData.name"></el-input>
    </el-form-item>
    <el-form-item label="里程前缀" prop="mileageIdentification">
      <el-input :readonly="_readonly" v-model="fromData.mileageIdentification">
        <!-- <template slot="prepend">{{fromData.mileageIdentification}}</template> -->
      </el-input>
    </el-form-item>
    <el-form-item label="开始里程" prop="startMileage">
      <el-input :readonly="_readonly" v-model="fromData.startMileage"></el-input>
    </el-form-item>
    <el-form-item label="结束里程" prop="endMileage">
      <el-input :readonly="_readonly" v-model="fromData.endMileage"></el-input>
    </el-form-item>
    <el-form-item label="施工单位" prop=" constructionOrg">
      <el-input :readonly="_readonly" v-model="fromData.constructionOrg"></el-input>
    </el-form-item>
    <el-form-item label="监理单位" prop="supervisingOrg">
      <el-input v-model="fromData.supervisingOrg"></el-input>
    </el-form-item>
    <el-form-item label="备注 " prop="remark">
      <el-input :readonly="_readonly" type="textarea" v-model="fromData.remark"></el-input>
    </el-form-item>
  </el-form>

  <el-form v-else-if="type==1" :model="fromData" :rules="fromData_rules" ref="fromDataRef" label-width="100px">
    <el-form-item label="名称" prop="name">
      <el-input :readonly="_readonly" v-model="fromData.name"></el-input>
    </el-form-item>
    <el-form-item label="里程前缀" prop="mileageIdentification">
      <el-input :readonly="_readonly" v-model="fromData.mileageIdentification">
      </el-input>
    </el-form-item>
    <el-form-item label="开始里程" prop="startMileage">
      <el-input :readonly="_readonly" v-model="fromData.startMileage"></el-input>
    </el-form-item>
    <el-form-item label="结束里程" prop="endMileage">
      <el-input :readonly="_readonly" v-model="fromData.endMileage"></el-input>
    </el-form-item>
    <!-- <el-form-item label="施工单位" prop=" constructionOrg">
      <el-input :readonly="_readonly" v-model="fromData.constructionOrg"></el-input>
    </el-form-item> -->
    <!-- <el-form-item label="监理单位" prop="supervisingOrg">
      <el-input v-model="fromData.supervisingOrg"></el-input>
    </el-form-item> -->
    <el-form-item label="备注 " prop="remark">
      <el-input :readonly="_readonly" type="textarea" v-model="fromData.remark"></el-input>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  props: {
    fromData: {},
    _readonly: {
      type: Boolean,
      default: false
    },
    type: null
  },
  data() {
    return {
      fromData_rules: {
        name: [{ required: true, message: '请输入名称', trigger: 'change' }],
        mileageIdentification: [{ required: true, message: '请输入里程前缀', trigger: 'change' }],
        startMileage: [{ required: true, message: '请输入开始里程', trigger: 'change' }],
        endMileage: [{ required: true, message: '请输入结束里程', trigger: 'change' }]
      }
    }
  },
  methods: {
    validate() {
      let res_bool = false
      this.$refs.fromDataRef.validate(bool => {
        res_bool = bool
      })
      return res_bool
    },
    resetFields() {
      this.$refs.fromDataRef.resetFields()
    }
  }
}
</script>

<style>
</style>